def calculate_boeyi_indicators(klines):
    """
    计算博易大师技术指标，包含Q值、操盘线和空头线
    """
    close = klines.close
    open_price = klines.open
    high = klines.high
    low = klines.low
    
    # 计算Q值
    Q = (3*close + low + open_price + high) / 6
    Q = pd.Series(Q)
    
    # 手动实现 REF 函数
    def ref(series, n=1):
        return series.shift(n)
    
    # 计算操盘线（26期Q值加权平均）
    terms = [
        26 * Q,
        25 * ref(Q, 1),
        24 * ref(Q, 2),
        23 * ref(Q, 3),
        22 * ref(Q, 4),
        21 * ref(Q, 5),
        20 * ref(Q, 6),
        19 * ref(Q, 7),
        18 * ref(Q, 8),
        17 * ref(Q, 9),
        16 * ref(Q, 10),
        15 * ref(Q, 11),
        14 * ref(Q, 12),
        13 * ref(Q, 13),
        12 * ref(Q, 14),
        11 * ref(Q, 15),
        10 * ref(Q, 16),
        9 * ref(Q, 17),
        8 * ref(Q, 18),
        7 * ref(Q, 19),
        6 * ref(Q, 20),
        5 * ref(Q, 21),
        4 * ref(Q, 22),
        3 * ref(Q, 23),
        2 * ref(Q, 24),
        ref(Q, 25)
    ]
    trading_line = sum(terms) / 351
    
    # 手动实现 EMA 函数
    def ema(series, n=10):
        return series.ewm(span=n, adjust=False).mean()
    
    # 计算空头线（操盘线的7期EMA）
    short_line = ema(trading_line, 7)
    
    # 计算买卖信号
    signals = pd.Series(np.nan, index=close.index)
    for i in range(2, len(close)):
        if trading_line.iloc[i-1] < short_line.iloc[i-1] and trading_line.iloc[i] > short_line.iloc[i]:
            signals.iloc[i] = 1  # 买入信号
        elif trading_line.iloc[i-1] > short_line.iloc[i-1] and trading_line.iloc[i] < short_line.iloc[i]:
            signals.iloc[i] = -1  # 卖出信号

    return trading_line, short_line, signals